<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-3.3.1.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/jquery.datetimepicker.css">
	<script src="${pageContext.request.contextPath }/static/js/jquery.datetimepicker.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/ion.calendar.css">
	<script src="${pageContext.request.contextPath }/static/js/moment.min.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/moment.zh-cn.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/ion.calendar.min.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/static/css/avgrund.css">
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/avgrund.js"></script>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/menu_sideslide.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/normalize.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/bootstrap.min.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/bootstrap.min.js"></script>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/iconfont.css" />
	<link rel="shortcut icon" href="../../img/favico.ico" type="image/x-icon">
	<style>
        .weather{
           margin: 30px 0 20px 30px;
        }
        .content-left{
            float: left;
            border-right: 1px solid #ddd;
            width: 100%;
            box-shadow: 2px 2px 4px #777777;
            margin-top: 3px;
        }
        .content-left-weather{
            margin: 0 auto;
            border-bottom:  1px solid #ddd;
            width: 100%;
        }
        .mynavbar{
            position: relative;
        }
        .menu-button{
            position: absolute;
            top: -10px;
            left:-5px;
        }
    </style>
	
	<script type="text/javascript">
		

        $(function(){
            $("#calendar").ionCalendar({
                lang: 'zh-cn',
                format: 'YYYY年M月D日',
                onClick: function(date){
                	var code = "<%=request.getParameter("code")%>";
                	
                	if(code==1){
                	var time=new Date(Date.parse(date.replace('年','-').replace('月','-').replace('日','')))
                    console.log(time)
                    var d=new Date(time);
                    var year=d.getFullYear();
                    var month=change(d.getMonth()+1);
                    var day=change(d.getDate());
                    var time=year+'-'+month+'-'+day;
                    
                    openDialog();
                    function change(t){
                        if(t<10){
                            return "0"+t;
                        }else{
                            return t;
                        }
                    }
                    var user="<%=request.getParameter("user")%>"
                    var param_data={
                    	'user':user,
                    	'start_date':time
                    }
                   $.ajax({
                    	type:"POST",
                        url:"${pageContext.request.contextPath }/selectSchedule.action",
                        data:{'param':JSON.stringify(param_data)},
                        dataType:"json",
                        async:false,
                        success:function(data){
                        	console.log(data)
                            if(data != ""){
           						var tbl=""
           						
           						var text3="edit_sch"
                       		 	for(var i=0;i<data.length;i++){
                       		 	var text1="${pageContext.request.contextPath }/deleteSchedule.action?id="+data[i].id
               					var text2="${pageContext.request.contextPath }/SelectOne.action?id="+data[i].id
                       			 tbl+="<p><span>主题</span>：<span>"+data[i].theme+"</span></p><p><span>开始时间</span>：<span>"+data[i].start_date+" "+data[i].start_time+"</span></p><p><span>结束时间</span>：<span>"+data[i].end_date+" "+data[i].end_time+"</span></p><p><span>人员</span>：<span>"+data[i].staff+"</span></p><p><span>说明</span>：<span>"+data[i].instruction +"</span></p>"+"<p><a href='"+text1+"' style='margin-right:15px'>删除</a>"+"<a href='"+text2+"' class='"+text3+"'>修改</a></p>"
                       		}  		    	
                 		     $(".detail_content").html(tbl);
                            }else{       
                            	$(".detail_content").html("您没有添加事件");
                            }
                        }
                    });
                }else{
                	alert("您还未登录！");
                }
                }
            
            });
            $(function () {
				$("#shouye").click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					
					if(code==1 ){
						location.href="main.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });
				$("#schedu").click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					if(code==1){
						location.href="../../jsp/schedule.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });
				$("#daojishi").click(function () {
					var code = "<%=request.getParameter("code")%>";
					
					if(code==1){
						location.href="../../jsp/backtime.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					}
					
                });

	           $("#rob").click(function () {	
					var code = "<%=request.getParameter("code")%>";
					if(code==1){
 						location.href="../../jsp/robot.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					} 					
                });	
	           $("#message").click(function () {	
					var code = "<%=request.getParameter("code")%>";
					if(code==1){
						location.href="../../jsp/message.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					} 					
               });	
	         $(".lianliankan").click(function(event){
	        	   //event.preventDefault();
	        	   var code = "<%=request.getParameter("code")%>";
					if(code==1){
						location.href="../../jsp/lianliankan.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					} 	
	           });
	           $(".pingtu").click(function(event){
	        	   //event.preventDefault();
	        	   var code = "<%=request.getParameter("code")%>";
					if(code==1){
						location.href="../../jsp/pingtu.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					} 	
	           }); 
	           $("#set").click(function(event){
	        	   //event.preventDefault();
	        	   var code = "<%=request.getParameter("code")%>";
					if(code==1){
						location.href="../../jsp/setinfo.jsp?code="+<%=request.getParameter("code")%>+"&user="+"<%=request.getParameter("user")%>";
					}
					else{
						alert("您还未登录！");
					} 	
	           }); 
				
            });
        });


	</script>
	
	<script type="text/javascript">

        function openDialog() {
            Avgrund.show( "#default-popup" );
        }

        function closeDialog() {
            Avgrund.hide();
        }

	</script>
	<script type="text/javascript">
        $(document).ready(function(){
        	var code = "<%=request.getParameter("code")%>";
        	if(code==0){
        		 
                var ch22 = document.getElementById("login");
                ch22.style.visibility="visible";
        	}else if(code==1){
        		
                 
                var ch22 = document.getElementById("login");
                ch22.style.visibility="hidden";
        	}
        	
        });
    </script>
    <script type="text/javascript">
    	function daojishi(time,callback){
    		
   			window.setInterval(function(){
   				var currenttime=new Date();
   				var currentTime = currenttime.getTime();
   				var nexttime = new Date(time); 
   	            var nextTime = nexttime.getTime();
   	            var allTime = nextTime - currentTime;
   	            var allSecond = parseInt(allTime / 1000);
   				
   	            // 8.转化   重要
   	            var d = size(parseInt(allSecond / 3600 / 24));
   	            var h = size(parseInt(allSecond / 3600 % 24));
   	            var m = size(parseInt(allSecond / 60 % 60));
   	            var s = size(parseInt(allSecond  % 60));
   	  	        callback&&callback(d,h,m,s);
   			},1000);
   			 
   	
    	}
    	daojishi('2019/06/15 09:00:00',function(d,h,m,s){
    		//console.log(d,h,m,s);
    		$('.card-djs1').html('<p>2019年6月英语四级考试时间：6月15日</p>'+'倒计时'+d+'天'+h+'小时'+m+'分钟'+s+'秒');
    	});
    	daojishi('2019/06/15 15:10:00',function(d,h,m,s){
    		//console.log(d,h,m,s);
    		$('.card-djs3').html('<p>2019年6月英语六级考试时间：6月15日</p>'+'倒计时'+d+'天'+h+'小时'+m+'分钟'+s+'秒');
    	});
    	daojishi('2019/12/15 00:00:00',function(d,h,m,s){
    		//console.log(d,h,m,s);
    		$('.card-djs2').html('<p>2020考研初试大约在12月中旬</p>'+'倒计时'+d+'天'+h+'小时'+m+'分钟'+s+'秒');
    	});
    		function size(num) {
    	        return num >= 10 ? num : '0' + num;
    	    }
    		
    		
			
    </script>
    <script>
    	$(function(){
    		var user="<%=request.getParameter("user")%>";
    		var code = "<%=request.getParameter("code")%>";
    		if(code == 1){
    			
    		
    		$.ajax({        			
    			type:"GET",
    		    url:"/Schedule/findPerson.action",
    		    contentType:"application/json;charset=utf-8",  
    		    //我们使用 JSON.stringify() 方法处理json，将其转换为字符串；
    		    data:{
    		    	'user':user
    		    },
    		    dataType:"json",
    		    async:false,
    		    success:function(result){
    		   
    		    	 if(result.code==1){
    		    		
    		    		 var data=result.data;
    		    		 //console.log(data.avatar);
    		    		 var img = ""
    		    		 if(data.avatar === undefined){
    		    			 img = '../../img/touxiang.jpg'
    		    		 }else{
    		    			 img = '/image/'+data.avatar
    		    		 }
    		    	$(".touxiang").attr('src',img);		        		    		  		    
             		 $("#left-name").html(data.name);
             		 $("#left-phone").html(data.phone);
    		    	 }else if(result.code==-1){
    		    		 alert("获取用户失败");
    		    	 }      		    	
    		    }        		    
    		});
    		}else{
    			//alert('您还未登录');
    		}
    	});
    </script>
   
    <script>
    	$(function(){
    		
    		//获得今日的日程
    		function getNowTime() {
		        var date = new Date();
		        var seperator1 = "-";//年月日分隔符
		        var seperator2 = ":";//时分秒分隔符
		        var month = date.getMonth() + 1; //月份是0~11，要加1为当前月
		        var strDate = date.getDate();
		        if (month >= 1 && month <= 9) {
		            month = "0" + month;
		        }
		        if (strDate >= 0 && strDate <= 9) {
		            strDate = "0" + strDate;
		        }
		        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate 
		        return currentdate;
		    }
    		
    		var user="<%=request.getParameter("user")%>";
    		var code = "<%=request.getParameter("code")%>";
    		 var param_datas={
                 	'user':user,
                 	'start_date':getNowTime()
                 }
    		 //console.log(param_datas);
    		 if(code == 1){
    			 $.ajax({
                 	type:"POST",
                     url:"${pageContext.request.contextPath }/selectSchedule.action",
                     data:{'param':JSON.stringify(param_datas)},
                     dataType:"json",
                     async:false,
                     success:function(data){
                     	//console.log(data)
                     	 var tbl = "";
                         if(data != ""){
        						
        						for(var i = 0;i<data.length;i++){
        							
        							tbl +="<div class='alert alert-warning alert-dismissible fade show' role='alert'>"
                                    tbl += "<strong>"+data[i].theme+"</strong>"
        							tbl += "<span class=' float-right' style='font-size:16px'>"+data[i].start_date+" "+data[i].start_time+"</span></div>"
        							
        						}
        						$('.today-schedule').html(tbl);
                    		}  		    	
                         else{
                        	 tbl = "<div class='alert alert-success' role='alert'>"
                        	 tbl += "<h4 class='alert-heading'>Well done!</h4> <hr>"
                        	 tbl += "<p class='mb-0'>You have no agenda for today,Enjoy the day.</p></div>"
                             $('.today-schedule').html(tbl);
                         }
                     }
                 });
    		 }else{
    			 //alert('您还未登录');
    		 }
    		 
    	});
    </script>
    
<title>时间安排</title>
</head>
<body >

			<div class="menu-wrap" >
						<div class="media" style="padding: 10px 50px;width: 300px;position:absolute;top:20px;left:0;border-bottom:1px solid #e8e8e8">
				            <img class="mr-3 touxiang" src="../../img/touxiang.jpg" style="width: 48px;height: 48px;border-radius: 50%">
				            <div class="media-body">
				                <h5 class="mt-0" style="font-size: 14px;color:#fff" id="left-name">未登录</h5>
				                <span style="font-size: 13px;color:#fff" id="left-phone"></span>
				            </div>
        				</div>
        			
						<div class="today-schedule" style="width:299px;position:absolute;top:93px;left:0;overflow:auto">
							
							
						</div>
  
				<div  class="out" style="position:absolute;left:15px;bottom:15px;font-size:14px">
					<a id="set" data-target="" href="#" style="margin-right:20px"><i class="iconfont" style="margin-right:5px">&#xe61c;</i><span>设置</span></a>
					<a id="loginout" data-target="" href="main.jsp?code=0"><i class="iconfont" style="margin-right:5px">&#xe792;</i><span>退出</span></a>
				</div>
				
				<button class="close-button" id="close-button">Close Menu</button>
			</div>
<header>
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark mynavbar">
            <div class="navbar-brand"><button class="btn btn-dark" id="open-button">个人中心</button></div>
            <div class="collapse navbar-collapse" id="navbarNavDropdown" style="margin-left: 100px">
                <ul class="navbar-nav">
                    <li class="nav-item active" id='shouye'>
                        <a class="nav-link" href="#" style="margin-left:200px">首页<span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item" id="schedu">
                        <a class="nav-link" href="#">日程安排</a>
                    </li>
                    <li class="nav-item" id='daojishi'>
                        <a class="nav-link" href="#">倒计时</a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                           小游戏
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item pingtu" href="#" id="pt">拼图</a>
                            <a class="dropdown-item lianliankan" href="#">连连看</a>
                        </div>
                    </li>
                    <li class="nav-item" id='rob'>
                        <a class="nav-link" href="#" >智能机器人</a>
                    </li>
                </ul>
            </div>
            <ul class="nav">
                <li class="nav-item">
                    <a class="nav-link disabled" href="#" id="message" style="color:#fff"><i class="iconfont" style="margin-right:5px">&#xe605;</i>消息</a>
                </li>
                <li class="nav-item" id="login">
                	
                    <a class="nav-link disabled" href="../../jsp/login.jsp" style="color:#fff"><i class="iconfont" style="margin-right:5px">&#xe63a;</i>login</a>
                </li>
            </ul>
        </nav>
    </header>
	<div class="container-fluid" >
        <div class="row">
            <div class="content-left col-md-3 d-none d-lg-block" >
                <div class="content-left-weather ">
                    <iframe class="weather" name="weather_inc" src="http://i.tianqi.com/index.php?c=code&id=55"  width="255" height="294" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
                </div>
                <div class="">
                    <div class="jq22" style="width: 300px;margin-top: 35px;margin-left: 25px;margin-bottom: 60px">
                        <div id="calendar"></div>
                    </div>
                </div>
            </div>
            <div class="content-right col-md-9" style="margin-top: 8px">
                <div style="overflow: hidden">
                    <div class="card" style="width: 18rem;float: left;margin-right: 18px;min-height:400px">
                        <img class="card-img-top" src="../../img/siji.jpg" alt="Card image cap" style="height:185px">
                        <div class="card-body">
                            <h5 class="card-title">四级</h5>
                            <p class="card-text card-djs1" style="font-size:14px"></p>
                            <a href="../../jsp/schedule.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>" class="btn btn-primary">Make Schedule</a>
                        </div>
                    </div>
                <div class="card" style="width: 18rem;float: left;margin-right: 18px;min-height:400px">
                    <img class="card-img-top" src="../../img/kaoyan.jpg" alt="Card image cap" style="height:185px">
                    <div class="card-body">
                        <h5 class="card-title">考研</h5>
                        <p class="card-text card-djs2" style="font-size:14px"></p>
                        <a href="../../jsp/schedule.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>" class="btn btn-primary">Make Schedule</a>
                    </div>
                </div>
                <div class="card" style="width: 18rem;float: left;margin-right: 18px;min-height:400px" >
                        <img class="card-img-top" src="../../img/liuji.jpg" alt="Card image cap" style="height:185px">
                        <div class="card-body">
                            <h5 class="card-title">六级</h5>
                            <p class="card-text card-djs3" style="font-size:14px"></p>
                            <a href="../../jsp/schedule.jsp?code=<%=request.getParameter("code") %>&user=<%=request.getParameter("user") %>" class="btn btn-primary">Make Schedule</a>
                        </div>
                    </div>
                </div>
                <div class="jumbotron jumbotron-fluid" style="margin-top: 15px">
                    <div class="container">
                        <h1 class="display-4">TIME</h1>
                        <p class="lead">An inch of time is an inch of gold, an inch of gold can't buy an inch of time</p>
                    </div>
                </div>

            </div>
        </div>
    </div>

<div class="avgrund-cover"></div>
<aside id="default-popup" class="avgrund-popup" style=''>
	<h2 style="font-size:18px">今日安排</h2>
	<div class="detail_content" style="height: 190px;overflow: auto" >
		
	</div>
	<button class="btn btn-primary" onClick="javascript:closeDialog();" style="position:absolute;bottom:10px;right:20px">Close</button>

</aside>
    <script src="${pageContext.request.contextPath }/static/js/classie.js"></script>
	<script src="${pageContext.request.contextPath }/static/js/main.js"></script>
	
</body>
</html>